let  popup = document.querySelector(".popup");
let popupBg = document.querySelector(".popupBg");

let popupLeft = document.querySelectorAll(".popupLeft div");
let popupRight = document.querySelectorAll(".popupRight div");

function mouseOver(x){
    x.style.display = 'block';
}
function mouseOut1(x) {
    x.style.display = 'none';
}
function mouseOut(x,y){
    x.style.display = 'none';
    for(let content of y){
        content.style.backgroundColor = '#fff';
        content.style.color= 'rgba(0, 0, 0, 0.7)' ;
    }
}
popupLeft.forEach((items ,index) =>{
    popupLeft[index].onmouseover = function (){
        for(let content of popupLeft){
            content.style.backgroundColor = '#fff';
            content.style.color= 'rgba(0, 0, 0, 0.7)' ;
        }
        for(let content of popupRight){
            content.style.display = 'none';
        }
        popupLeft[index].style.color= '#000' ;
        popupLeft[index].style.backgroundColor = '#f6f6f6';
        popupRight[index].style.display = 'block';
    }
})

//智能办公弹窗
let hotActPopup = document.querySelector(".hotActPopup");

hotActPopup.onmouseover = function (){
    hotActPopup.style.display = 'block';
}

//解决方案弹窗
let solutionPopup = document.querySelector(".solutionPopup");
let solutionPopupA = document.querySelectorAll(".solutionPopupA");

solutionPopupA.forEach((items,index) =>{
    solutionPopupA[index].onmouseover = function (){
        for(let content of solutionPopupA){
            content.style.backgroundColor = '#fff';
            content.style.color= 'rgba(0, 0, 0, 0.7)' ;
        }
        this.style.color = '#005EFF';
        this.style.backgroundColor = '#f6f6f6';
    }
})
/*支持与服务弹窗*/
let supportPopup = document.querySelector(".supportPopup");
let supportPopupA = document.querySelectorAll(".supportPopupA");


supportPopupA.forEach((items,index) =>{
    supportPopupA[index].onmouseover = function (){
        for(let content of supportPopupA){
            content.style.backgroundColor = '#fff';
            content.style.color= 'rgba(0, 0, 0, 0.7)' ;
        }
        items.style.color = '#005EFF';
        items.style.backgroundColor = '#f6f6f6';
    }
})
// 中文弹窗
let chinaPopup = document.querySelector(".chinaPopup");
let chinaPopupA = document.querySelectorAll(".chinaPopupA");

chinaPopupA.forEach( (items,index) =>{
    chinaPopupA[index].onmouseover = function (){
        for(let content of chinaPopupA){
            content.style.backgroundColor = '#fff';
            content.style.color= 'rgba(0, 0, 0, 0.7)' ;
        }
        items.style.color = '#005EFF';
        items.style.backgroundColor = '#f6f6f6';
    }
})

//动态导航栏
let nav=document.querySelector(".nav");
let edu=document.querySelector(".edu");
let hun=document.querySelector(".hun");
let ser=document.querySelector(".ser");
let broad=document.querySelector(".broad");
let as=document.querySelectorAll(".nav-con a");

// let nav1=document.querySelector(".nav1");

let navH=nav.offsetTop;
let eduH=edu.offsetTop;
let hunH=hun.offsetTop;
let serH=ser.offsetTop;
let broadH=broad.offsetTop;
// console.log(hunH);
// as.forEach((item,index)=>{
//     item.onclick=function (){
//         window.scrollTo({
//             top:document.querySelector("#p"+this.id.substr(1)).offsetTop - 50,
//             behavior:"smooth"
//         })
//     }
// })

window.onscroll=function (){
    // 获取滚动条高度
    let scollH=document.documentElement.scrollTop||document.body.scrollTop;
    // 判断
    if(scollH>=navH){
        // 给当前导航栏设置固定定位
        nav.style.position="fixed";
        nav.style.top=0;
    }else{
        // 恢复成默认的标准文档流  静态定位
        nav.style.position="static";
    }

}
//跳转
let hundred=document.querySelector(".hundred");
hundred.onclick=function (){
    window.scrollTo({
        top:hunH-51,
        behavior:"smooth"
    })
}
let education=document.querySelector(".education");
education.onclick=function (){
    window.scrollTo({
        top:eduH-100,
        behavior:"smooth"
    });
}
let service=document.querySelector(".service");
//滚动条滚动 scrollTo方法  behavior是行为  smooth光滑的
service.onclick=function (){
    window.scrollTo({
        top:serH-100,
        behavior:"smooth"
    });
}
let broadcast=document.querySelector(".broadcast");
broadcast.onclick=function (){
    window.scrollTo({
        top:broadH-100,
        behavior:"smooth"
    });
}



//轮播图
let ul=document.querySelector(".top-img");
let dot=document.querySelectorAll(".top-dot li");
let i=1;
let timer=null;
// 开启定时器
timer=setInterval(()=>{
    ul.style.cssText="transition-duration: 0.3s;transform: translateX(-"+ 1920*i +"px);left:0px";

    if(i%2==0){
        i=0;
        setTimeout(()=>{
            ul.style.cssText="transform: translateX(0px);left:0px"
        },1000);
    }
    i++;
},2000);


//移入事件  当移入照片时会出现一个播放的图标
let boxContents=document.querySelectorAll(".box-content");
let boxImg=document.querySelector(".box-img");
let boxa=document.querySelector(".box-a");
let players=document.querySelectorAll(".player");

players.forEach((item,index)=>{
    item.onmouseover=function (){
        item.className="active";
    }
    item.onmouseout=function (){
        item.className="player";
    }
})
boxContents.forEach((item)=>{
    item.onclick=function (){
        window.location.href="xx.html";
    }
})

//底部事件
//底部图标变换事件

let footerTwoLeftIcon1 = document.querySelector(".footerTwoLeftIcon1");
let footerTwoLeftIcon2 = document.querySelector(".footerTwoLeftIcon2");
let footerTwoLeftIcon3 = document.querySelector(".footerTwoLeftIcon3");
let footerTwoLeftIcon4 = document.querySelector(".footerTwoLeftIcon4");

let footerRightIcon1 = document.querySelector(".footerRightIcon1");
let footerRightIcon2 = document.querySelector(".footerRightIcon2");

let footerPopup1 = document.querySelector(".footerPopup1");
let footerPopup2 = document.querySelector(".footerPopup2");
let footerPopup3 = document.querySelector(".footerPopup3");

let footerPopup4 = document.querySelector(".footerPopup4");
let footerPopup5 = document.querySelector(".footerPopup5");


function mouseoverFooterleft(x){
    if (x == 1){
        footerTwoLeftIcon1.className = 'footerTwoLeftIcon1off';
    }else if (x == 2){
        footerTwoLeftIcon2.className = 'footerTwoLeftIcon2off';
        footerPopup1.style.display = 'block';
    }else if (x == 3){
        footerTwoLeftIcon3.className = 'footerTwoLeftIcon3off';
        footerPopup2.style.display = 'block';
    }else if (x == 4){
        footerTwoLeftIcon4.className = 'footerTwoLeftIcon4off';
        footerPopup3.style.display = 'block';
    }
}
function mouseoutFooterleft(x){
    if (x == 1){
        footerTwoLeftIcon1.className = 'footerTwoLeftIcon1';
    }else if (x == 2){
        footerTwoLeftIcon2.className = 'footerTwoLeftIcon2';
        footerPopup1.style.display = 'none';
    }else if (x == 3){
        footerTwoLeftIcon3.className = 'footerTwoLeftIcon3';
        footerPopup2.style.display = 'none';
    }else if (x == 4){
        footerTwoLeftIcon4.className = 'footerTwoLeftIcon4';
        footerPopup3.style.display = 'none';
    }
}
function mouseoverFooterRight(x){
    if (x == 5){
        footerRightIcon1.className = 'footerRightIcon1off'
        footerPopup4.style.display = 'block';
    }else if(x == 6){
        footerRightIcon2.className = 'footerRightIcon2off'
        footerPopup5.style.display = 'block';
    }
}
function mouseoutFooterRight(x){
    if (x == 5){
        footerRightIcon1.className = 'footerRightIcon1'
        footerPopup4.style.display = 'none';
    }else if(x == 6){
        footerRightIcon2.className = 'footerRightIcon2'
        footerPopup5.style.display = 'none';
    }
}
